#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QtSerialPort/QtSerialPort>

#include <QtCore/qiodevice.h>

#include <QtSerialPort/qserialportglobal.h>

#include "string.h"
#include "mythread.h"

namespace Ui {
class MainWindow;
}


#define ARRAY_SIZE(x) sizeof(x)/sizeof(x[0])
#define packge_size  1024
class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();
public:
    void get_avaiable_port(void);
    void Browser(void);
    void open_send_file(QString file);
    qint64 func_send_data(const char *data, qint64 len);
private slots:
    void on_Button_select_file_clicked();

    void on_Button_send_file_clicked();

    void on_lineEdit_textEdited(const QString &arg1);

    void on_Button_Open_Port_clicked();

    void on_Button_send_clicked();

    void readData(void);

    void on_pushButton_clear_clicked();

    void on_textBrowser_re_textChanged();
    char ConvertHexChar(char ch);


    void on_checkBox_save_log_clicked();

    void on_checkBox_save_log_clicked(bool checked);

    void on_comboBox_Bandrate_currentIndexChanged(int index);

private:
    Ui::MainWindow *ui;
    QString send_file;
    QFile fd_log;
    QSerialPort* port;
    uint64_t send_count;
    uint64_t rec_count;
    qint32 band_rate;
    QSerialPort::StopBits stop_bits;
    QSerialPort::DataBits data_bits;
    mythread thread_receive;
};

#endif // MAINWINDOW_H
